using System;
using CHEnhanceEfCore.Common;
using CHEnhanceEfCore.Config.MQ.factory;
using CHEnhanceEfCore.Config.MQ.listen;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;

namespace CHEnhanceEfCore.Config.MQ.config
{
    /// <summary>
    /// author: chenhao
    /// </summary>
    public static class MQRegisterComponent
    {
        public static IServiceCollection serviceCollection { get; set; }

        public static void RegisterMq(this IApplicationBuilder app)
        {
            OperationalComponentUtil.serviceProvider = app.ApplicationServices;
            //这里采用的是rabbitmq factory
            serviceCollection.AddHostedService<MqService>();
            Console.WriteLine("config rabbitMq success");
        }
    }
}